package com.company.nuwa.common.enumration;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * <p>验证码类型</p >
 *
 * @author Lionel Lee
 * @version 1.0: PictureCaptchaTypeEnum.java
 * @date 2019/12/18 16:44
 */
@AllArgsConstructor
public enum PictureCaptchaTypeEnum implements BaseEnum {

    /**
     * 数字
     */
    NUMBER(0, "数字"),

    /**
     * 字母
     */
    ALPHABET(1, "字母"),
    /**
     * 混合类型
     */
    MIX(2, "数字和字母混合");
    /**
     * 编码
     */
    @Getter
    private Integer value;

    /**
     * 说明
     */
    @Getter
    private String intro;

    public static PictureCaptchaTypeEnum getByCode(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        for (PictureCaptchaTypeEnum temp : PictureCaptchaTypeEnum.values()) {
            if (temp.getValue().intValue() == code.intValue()) {
                return temp;
            }
        }
        return null;
    }
}